home *** CD-ROM | disk | FTP | other *** search
- // Sysbench main file
- //#define INCL_NOCOMMON
- #define INCL_DOSMISC
- #define INCL_DOSDEVICES
- #define INCL_DOSPROCESS
- #define INCL_DOSDEVIOCTL
- //#define INCL_DOSSEMAPHORES
- #define INCL_DOSERRORS
- #define INCL_WINWINDOWMGR
- #define INCL_WINMESSAGEMGR
- #define INCL_WINFRAMEMGR
- #define INCL_WINDIALOGS
- #define INCL_WININPUT
- #define INCL_WINSWITCHLIST
- #define INCL_WINPROGRAMLIST
- #define INCL_WINERRORS /* Window Error Functions */
- #define INCL_WINDESKTOP
- #define INCL_WINSTDFILE
- #define INCL_GPICONTROL
- #define INCL_GPIPRIMITIVES
-
- #define INCL_WIN
- #define INCL_PM
- #define IDM_RESOURCE 1
- #define INCL_GPI
- #define INCL_GPILCIDS
- #define INCL_GPIPRIMITIVES
-
- #include <os2.h>
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "types.h"
- #include "pmb.h"
- #include "pmb_bench.h"
- #include "pmb_datatype.h"
-
- #define CLS_CLIENT "SysBenchWindowClass"
- #define SYSB_VER "0.9.1"
- #define THR_DONE (WM_USER + 1)
- #define THR_UPDATE (WM_USER + 2)
- #define START_STACKSIZE 65536
- #define DISP_LINES (75)
- #define MB (1048576)
- #define KB 1024
- #define MN 1000000
-
- // ********** IMPORTED FUNCTIONS
- extern int pmb_diskio_disksize(int nr);
- extern int pmb_diskio_nrdisks(void);
- extern void log(char* s);
-
- // ********** EXPORTED FUNCTIONS
- void err(char* s);
- void InfoBox(char* s);
- void WarnBox(char* s);
- void ErrorBox(char* s);
-
- // ********** LOCAL FUNCTIONS
- static void SetTitle(char* s);
- static void UpdateWindow(HPS hpsPaint, PRECTL pRect, s32 scrollValue);
- static void Print(s32 row, s32 col, char* string, PRECTL pRect,
- s32 scrollValue, HPS hpsPaint, s32 color);
- static void SetMenuState(bool active);
- static void UpdateAll(void);
- static void SaveResults(void);
- static void PrintFile(s32 newlines, s32 col, char* string, FILE* fp);
-
- MRESULT EXPENTRY ClientWindowProc ( HWND hwndWnd,
- ULONG ulMsg,
- MPARAM mpParm1,
- MPARAM mpParm2 );
-
- // ********** EXPORTED DATA
- double test_time;
- static HWND hwndClient = NULLHANDLE;
- static HWND hwndVertScroll;
- static HWND hwndMenu;
-
- // ********** LOCAL DATA
- static bool thread_running;
- static s32 fontW;
- static s32 fontH;
- static HPS mainHps = NULLHANDLE;
- //static HAB hab = NULLHANDLE;
- static s32 scroll = 0;
- static s32 oldscroll = 0;
- static HWND hwndFrame = NULLHANDLE;
-
- struct glob_data data = {
- 1,
- 1,
- { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 },
- {
- {
- "Graphics",
- 8,
- {
- { "BitBlt S->S cpy", -1.0, MN, "Mpixels/s" },
- { "BitBlt M->S cpy", -1.0, MN, "Mpixels/s" },
- { "Filled Rectangle", -1.0, MN, "Mpixels/s" },
- { "Pattern Fill", -1.0, MN, "Mpixels/s" },
- { "Vertical Lines", -1.0, MN, "Mpixels/s" },
- { "Horizontal Lines", -1.0, MN, "Mpixels/s" },
- { "Diagonal Lines", -1.0, MN, "Mpixels/s" },
- { "Text Render", -1.0, MN, "Mpixels/s" }
- },
- -1.0,
- "PM-marks"
- },
- {
- "CPU integer",
- 4,
- {
- { "Dhrystone", -1.0, MN, "VAX 11/780 MIPS" },
- { "Hanoi", -1.0, 1, "moves/25 usec" },
- { "Heapsort", -1.0, MN, "MIPS" },
- { "Sieve", -1.0, MN, "MIPS" }
- },
- -1.0,
- "CPUint-marks"
- },
- {
- "CPU float",
- 3,
- {
- { "Linpack", -1.0, 1000, "MFLOPS" },
- { "Flops", -1.0, MN, "MFLOPS" },
- { "Fast Fourier Tr.", -1.0, 1, "VAX FFT's" }
- },
- -1.0,
- "CPUfloat-marks"
- },
- {
- "Direct Interface to video extensions - DIVE",
- 3,
- {
- { "Video bus bandw.", -1.0, MB, "MB/s" },
- { "DIVE fun", -1.0, 1, "fps at 640x480x256" },
- { "M->S, DD, 1.00:1", -1.0, 1, "fps at 640x480x256" }
- },
- -1.0,
- "DIVE-marks"
- },
- {
- "Disk I/O",
- 4,
- {
- { "Avg. data access time", -1.0, 1.0e-03, "ms" },
- { "Cache/Bus xfer rate ", -1.0, MB, "MB/s" },
- { "Average Transfer rate", -1.0, MB, "MB/s" },
- { "Disk use CPU load ", -1.0, 1, "percent" }
- },
- -1.0,
- "DiskIO-marks"
- },
- {
- "Memory",
- 27,
- {
- { "5 kB copy", -1.0, MB, "MB/s" },
- { "10 kB copy", -1.0, MB, "MB/s" },
- { "20 kB copy", -1.0, MB, "MB/s" },
- { "40 kB copy", -1.0, MB, "MB/s" },
- { "80 kB copy", -1.0, MB, "MB/s" },
- { "160 kB copy", -1.0, MB, "MB/s" },
- { "320 kB copy", -1.0, MB, "MB/s" },
- { "640 kB copy", -1.0, MB, "MB/s" },
- { "1280 kB copy", -1.0, MB, "MB/s" },
- { "5 kB read", -1.0, MB, "MB/s" },
- { "10 kB read", -1.0, MB, "MB/s" },
- { "20 kB read", -1.0, MB, "MB/s" },
- { "40 kB read", -1.0, MB, "MB/s" },
- { "80 kB read", -1.0, MB, "MB/s" },
- { "160 kB read", -1.0, MB, "MB/s" },
- { "320 kB read", -1.0, MB, "MB/s" },
- { "640 kB read", -1.0, MB, "MB/s" },
- { "1280 kB read", -1.0, MB, "MB/s" },
- { "5 kB write", -1.0, MB, "MB/s" },
- { "10 kB write", -1.0, MB, "MB/s" },
- { "20 kB write", -1.0, MB, "MB/s" },
- { "40 kB write", -1.0, MB, "MB/s" },
- { "80 kB write", -1.0, MB, "MB/s" },
- { "160 kB write", -1.0, MB, "MB/s" },
- { "320 kB write", -1.0, MB, "MB/s" },
- { "640 kB write", -1.0, MB, "MB/s" },
- { "1280 kB write", -1.0, MB, "MB/s" },
- },
- -1.0,
- "Mem-marks"
- }
- }
- };
-
-
- INT main ( VOID )
- {
- FATTRS fat;
- LONG match;
- FONTMETRICS fmMetrics ;
- HMQ hmq = NULLHANDLE;
- HAB hab = NULLHANDLE; /* PM anchor block handle */
- HAB hab1 = NULLHANDLE; /* PM anchor block handle */
- HWND hwndDeskTop;
- ERRORID erridErrorCode;/* last error id code */
- ULONG flCreate = 0UL;
- BOOL bLoop;
- QMSG qmsg;
- RECTL rect;
- s32 x,y,w,h, i;
- MENUITEM mi;
- HWND hwndPullDown;
- CHAR tmp[256];
- int rc = 1;
-
- if ( ( hab = WinInitialize ( 0UL ) ) == NULLHANDLE )
- exit(2);
-
- if ( ( hmq = WinCreateMsgQueue ( hab, 0UL ) ) == NULLHANDLE )
- exit(3);
-
- erridErrorCode = WinGetLastError(hab);
-
- rc = WinRegisterClass ( hab,
- CLS_CLIENT,
- ClientWindowProc,
- CS_SIZEREDRAW, /* CS_SYNCPAINT | */
- 0UL );
-
- erridErrorCode = WinGetLastError(hab);
-
- if ( rc != TRUE )
-
- {
- log("WinRegisterClass failed") ;
- exit(4);
- }
-
-
- flCreate = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MENU |
- FCF_MINMAX | FCF_TASKLIST | FCF_NOBYTEALIGN | FCF_VERTSCROLL;
-
- hwndDeskTop = WinQueryDesktopWindow(hab1,
- NULLHANDLE);
-
- hwndFrame = WinCreateStdWindow( hwndDeskTop,
- WS_VISIBLE,
- &flCreate,
- CLS_CLIENT,
- SYSB_VER,
- CS_SIZEREDRAW,
- NULLHANDLE,
- WND_MAIN,
- &hwndClient );
-
- erridErrorCode = WinGetLastError(hab);
-
- if ( hwndFrame == NULLHANDLE )
- {
- log("hwndFrame is NULLHANDLE");
- exit(6);
- }
-
-
- mainHps = WinGetPS(hwndClient);
-
- fat.usRecordLength = sizeof(FATTRS); /* sets size of structure */
- fat.fsSelection = 0; /* uses default selection */
- fat.lMatch = 0; /* does not force match */
- fat.idRegistry = 0; /* uses default registry */
- fat.usCodePage = 0; /* code-page 850 */
- fat.lMaxBaselineExt = 12L; /* requested font height is 12 pels */
- fat.lAveCharWidth = 8L; /* requested font width is 12 pels */
- fat.fsType = 0; /* uses default type */
- fat.fsFontUse = 0; /* doesn't mix with graphics */
-
- strcpy(fat.szFacename ,"System VIO");
-
- match = GpiCreateLogFont(mainHps, /* presentation space */
- NULL, /* does not use logical font name */
- 1L, /* local identifier */
- &fat); /* structure with font attributes */
-
- // match should now be 2 == FONT_MATCH */
-
- if (match != FONT_MATCH) {
- log("Can't get the right font");
- exit(1);
- }
-
- GpiSetCharSet(mainHps, 1L); /* sets font for presentation space */
-
- GpiQueryFontMetrics ( mainHps,
- sizeof ( fmMetrics ) ,
- &fmMetrics ) ;
-
- fontH = (14 * fmMetrics.lMaxBaselineExt)/10;
- fontW = fmMetrics.lMaxCharInc;
-
- GpiSetBackMix( mainHps, BM_OVERPAINT ); // how it mixes,
- GpiSetMix( mainHps, FM_OVERPAINT ); // how it mixes,
-
- hwndVertScroll = WinWindowFromID( hwndFrame, FID_VERTSCROLL);
-
- WinQueryWindowRect(HWND_DESKTOP, &rect);
- w = 636;
- h = (rect.yTop-rect.yBottom) - 40;
- x = (rect.xRight-rect.xLeft)/2 - w/2;
- y = 40;
- WinSetWindowPos(hwndFrame, false, x, y, w, h, SWP_SIZE | SWP_MOVE | SWP_ACTIVATE);
-
- WinQueryWindowRect(hwndClient, &rect);
-
- WinSendMsg( hwndVertScroll,
- SBM_SETSCROLLBAR,
- MPFROMSHORT(0),
- MPFROM2SHORT(0, (DISP_LINES * fontH) - (rect.yTop - rect.yBottom)));
-
- WinSendMsg( hwndVertScroll,
- SBM_SETTHUMBSIZE,
- MPFROM2SHORT(rect.yTop - rect.yBottom, DISP_LINES * fontH),
- NULL);
-
- SetTitle("Ready");
-
- thread_running = false;
-
-
- data.nr_fixed_disks = pmb_diskio_nrdisks();
- if (data.nr_fixed_disks > MAX_FIXED_DISKS) {
- log("Number of fixed disks is too high");
- exit(1);
- }
-
- for (i = 0; i < data.nr_fixed_disks; i++) {
- data.fixed_disk_size[i] = pmb_diskio_disksize(i);
- sprintf(tmp, "Disk %d: %d MB", i+1, data.fixed_disk_size[i]/(MB));
- hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
- WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(MI_MENU_DISKIO_SELECT, TRUE),
- (MPARAM) &mi);
- hwndPullDown = mi.hwndSubMenu;
- mi.iPosition = MIT_END;
- mi.afStyle = MIS_TEXT;
- mi.afAttribute = 0;
- mi.id = MI_MENU_DISKIO_SELECT+1+i;
- mi.hwndSubMenu = null;
- mi.hItem = 0;
- WinSendMsg(hwndPullDown, MM_INSERTITEM, (MPARAM) &mi,
- (MPARAM)tmp);
- }
-
- if (!data.nr_fixed_disks) {
- hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
- WinSendMsg(hwndMenu, MM_QUERYITEM, MPFROM2SHORT(MI_MENU_DISKIO_SELECT, TRUE),
- (MPARAM) &mi);
- hwndPullDown = mi.hwndSubMenu;
- mi.iPosition = MIT_END;
- mi.afStyle = MIS_TEXT;
- mi.afAttribute = 0;
- mi.id = MI_MENU_DISKIO_SELECT+1;
- mi.hwndSubMenu = null;
- mi.hItem = 0;
- WinSendMsg(hwndPullDown, MM_INSERTITEM, (MPARAM) &mi,
- (MPARAM)"No fixed disks found");
-
- WinEnableMenuItem(hwndMenu, MI_MENU_DISKIO, false);
- } else {
- hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
- WinCheckMenuItem(hwndMenu, MI_MENU_DISKIO_SELECT + 1, true);
- data.selected_disk = 0;
- sprintf(data.c[comp_disk].title, "Disk I/O - disk %d: %d MB", data.selected_disk+1, data.fixed_disk_size[data.selected_disk]/(MB));
- }
-
- WinEnableMenuItem(hwndMenu, MI_MENU_DIVE, true);
-
- UpdateAll();
-
- if ( hwndFrame != NULLHANDLE ) {
- bLoop = WinGetMsg ( hab,
- &qmsg,
- NULLHANDLE,
- 0,
- 0 );
- while ( bLoop ) {
- WinDispatchMsg ( hab, &qmsg );
- bLoop = WinGetMsg ( hab,
- &qmsg,
- NULLHANDLE,
- 0,
- 0 );
- }
-
- WinReleasePS(mainHps);
- WinDestroyWindow ( hwndFrame );
- }
-
- WinDestroyMsgQueue ( hmq );
- WinTerminate ( hab );
- return 0;
- }
-
- MRESULT EXPENTRY ClientWindowProc ( HWND hwndWnd,
- ULONG ulMsg,
- MPARAM mpParm1,
- MPARAM mpParm2 )
- {
- void *pv = null;
- static bool initialized = false;
- RECTL rect;
- s32 tmp;
- bool updateScroll;
- QMSG qmsgPeek;
- bool fDone;
- char tmps[256];
-
- switch ( ulMsg ) {
-
- case WM_CREATE:
- /* The client window has been created but is not visible yet. */
- /* Initialize the window here. */
- break;
-
- case WM_COMMAND:
-
- if (thread_running) {
- switch (SHORT1FROMMP(mpParm1)) {
- case MI_PROJ_QUIT:
- WinPostMsg(hwndWnd, WM_CLOSE, NULL, NULL);
- break;
- case MI_PROJ_ABOUT:
- InfoBox("SysBench "SYSB_VER" by Henrik Harmsen 1994-10-01.\n\nBug fixes by Trevor Hemsley 1996-05-18\nEmail: Trevor-Hemsley@dial.pipex.com\n"
- "Thanks to Kai Uwe Rommel for the disk IO tests, and Al Aburto for the CPU tests.");
- break;
- }
- return false;
- }
-
- if ((SHORT1FROMMP(mpParm1) > MI_MENU_DISKIO_SELECT) &&
- (SHORT1FROMMP(mpParm1) <= (data.nr_fixed_disks + MI_MENU_DISKIO_SELECT))) {
- s32 i, disk;
- disk = SHORT1FROMMP(mpParm1) - (MI_MENU_DISKIO_SELECT + 1);
- if (disk == data.selected_disk)
- return false;
- data.selected_disk = disk;
- for (i = 0; i < data.nr_fixed_disks; i++) {
- WinCheckMenuItem(hwndMenu, MI_MENU_DISKIO_SELECT + i + 1, false);
- }
- WinCheckMenuItem(hwndMenu, MI_MENU_DISKIO_SELECT + data.selected_disk + 1, true);
- sprintf(data.c[comp_disk].title, "Disk I/O - disk %d: %d MB", data.selected_disk+1, data.fixed_disk_size[data.selected_disk]/(MB));
- data.c[comp_disk].datalines[disk_avseek].value = -1.0;
- data.c[comp_disk].datalines[disk_busxfer].value = -1.0;
- data.c[comp_disk].datalines[disk_transf].value = -1.0;
- data.c[comp_disk].datalines[disk_cpupct].value = -1.0;
- data.c[comp_disk].total = -1.0;
- UpdateAll();
- return false;
- }
-
- switch (SHORT1FROMMP(mpParm1)) {
- case MI_PROJ_QUIT:
- WinPostMsg(hwndWnd, WM_CLOSE, NULL, NULL);
- break;
- case MI_PROJ_ABOUT:
- InfoBox("SysBench "SYSB_VER" by Henrik Harmsen 1994-10-01.\n\nBug fixes by Trevor Hemsley 1996-05-18\nEmail: Trevor-Hemsley@dial.pipex.com\n"
- "\nThanks to Kai Uwe Rommel for the disk IO tests, and Al Aburto for the CPU tests.");
- break;
- case MI_PROJ_SAVE:
- SaveResults();
- break;
- case MI_PROJ_ALL:
- SetTitle("Running All tests");
- SetMenuState(false);
- _beginthread(DoAll, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_BITBLIT_SS:
- SetTitle("Running BitBlit S->S");
- SetMenuState(false);
- _beginthread(DoGfxBlitBlitSS, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_BITBLIT_MS:
- SetTitle("Running BitBlit M->S");
- SetMenuState(false);
- _beginthread(DoGfxBlitBlitMS, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_FILLRECT:
- SetTitle("Running Filled Rectangle");
- SetMenuState(false);
- _beginthread(DoGfxFillRect, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_PATFIL:
- SetTitle("Running Pattern Fill");
- SetMenuState(false);
- _beginthread(DoGfxPatFil, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_VLINES:
- SetTitle("Running VerticalLines");
- SetMenuState(false);
- _beginthread(DoGfxVLines, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_HLINES:
- SetTitle("Running HorizontalLines");
- SetMenuState(false);
- _beginthread(DoGfxHLines, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_DLINES:
- SetTitle("Running DiagonalLines");
- SetMenuState(false);
- _beginthread(DoGfxDLines, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_TEXTRENDER:
- SetTitle("Running TextRender");
- SetMenuState(false);
- _beginthread(DoGfxTextRender, null, START_STACKSIZE, pv);
- break;
- case MI_GFX_ALL:
- SetTitle("Running All Graphics tests");
- SetMenuState(false);
- _beginthread(DoAllGraphics, null, START_STACKSIZE, pv);
- break;
- case MI_CPUINT_DHRY:
- SetTitle("Running Dhrystone");
- SetMenuState(false);
- _beginthread(DoCPUIntDhry, null, START_STACKSIZE, pv);
- break;
- case MI_CPUINT_HANOI:
- SetTitle("Running Hanoi");
- SetMenuState(false);
- _beginthread(DoCPUIntHanoi, null, START_STACKSIZE, pv);
- break;
- case MI_CPUINT_HEAPS:
- SetTitle("Running Heapsort");
- SetMenuState(false);
- _beginthread(DoCPUIntHeaps, null, START_STACKSIZE, pv);
- break;
- case MI_CPUINT_SIEVE:
- SetTitle("Running Sieve");
- SetMenuState(false);
- _beginthread(DoCPUIntSieve, null, START_STACKSIZE, pv);
- break;
- case MI_CPUINT_ALL:
- SetTitle("Running All CPU integer tests");
- SetMenuState(false);
- _beginthread(DoAllCPUInt, null, START_STACKSIZE, pv);
- break;
- case MI_CPUFLOAT_LINPACK:
- SetTitle("Running Linpack");
- SetMenuState(false);
- _beginthread(DoCPUFloatLinpack, null, START_STACKSIZE, pv);
- break;
- case MI_CPUFLOAT_FLOPS:
- SetTitle("Running FLOPS");
- SetMenuState(false);
- _beginthread(DoCPUFloatFlops, null, START_STACKSIZE, pv);
- break;
- case MI_CPUFLOAT_FFT:
- SetTitle("Running FFT");
- SetMenuState(false);
- _beginthread(DoCPUFloatFFT, null, START_STACKSIZE, pv);
- break;
- case MI_CPUFLOAT_ALL:
- SetTitle("Running All CPU float tests");
- SetMenuState(false);
- _beginthread(DoAllCPUFloat, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_5:
- SetTitle("Running Memcopy 5kB");
- SetMenuState(false);
- _beginthread(DoMem5, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_10:
- SetTitle("Running Memcopy 10kB");
- SetMenuState(false);
- _beginthread(DoMem10, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_20:
- SetTitle("Running Memcopy 20kB");
- SetMenuState(false);
- _beginthread(DoMem20, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_40:
- SetTitle("Running Memcopy 40kB");
- SetMenuState(false);
- _beginthread(DoMem40, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_80:
- SetTitle("Running Memcopy 80kB");
- SetMenuState(false);
- _beginthread(DoMem80, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_160:
- SetTitle("Running Memcopy 160kB");
- SetMenuState(false);
- _beginthread(DoMem160, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_320:
- SetTitle("Running Memcopy 320kB");
- SetMenuState(false);
- _beginthread(DoMem320, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_640:
- SetTitle("Running Memcopy 640kB");
- SetMenuState(false);
- _beginthread(DoMem640, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_1280:
- SetTitle("Running Memcopy 1280kB");
- SetMenuState(false);
- _beginthread(DoMem1280, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_5:
- SetTitle("Running Memory Read 5kB");
- SetMenuState(false);
- _beginthread(DoMemR5, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_10:
- SetTitle("Running Memory Read 10kB");
- SetMenuState(false);
- _beginthread(DoMemR10, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_20:
- SetTitle("Running Memory Read 20kB");
- SetMenuState(false);
- _beginthread(DoMemR20, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_40:
- SetTitle("Running Memory Read 40kB");
- SetMenuState(false);
- _beginthread(DoMemR40, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_80:
- SetTitle("Running Memory Read 80kB");
- SetMenuState(false);
- _beginthread(DoMemR80, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_160:
- SetTitle("Running Memory Read 160kB");
- SetMenuState(false);
- _beginthread(DoMemR160, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_320:
- SetTitle("Running Memory Read 320kB");
- SetMenuState(false);
- _beginthread(DoMemR320, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_640:
- SetTitle("Running Memory Read 640kB");
- SetMenuState(false);
- _beginthread(DoMemR640, null, START_STACKSIZE, pv);
- break;
- case MI_MEMR_1280:
- SetTitle("Running Memory Read 1280kB");
- SetMenuState(false);
- _beginthread(DoMemR1280, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_5:
- SetTitle("Running Memory Write 5kB");
- SetMenuState(false);
- _beginthread(DoMemW5, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_10:
- SetTitle("Running Memory Write 10kB");
- SetMenuState(false);
- _beginthread(DoMemW10, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_20:
- SetTitle("Running Memory Write 20kB");
- SetMenuState(false);
- _beginthread(DoMemW20, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_40:
- SetTitle("Running Memory Write 40kB");
- SetMenuState(false);
- _beginthread(DoMemW40, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_80:
- SetTitle("Running Memory Write 80kB");
- SetMenuState(false);
- _beginthread(DoMemW80, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_160:
- SetTitle("Running Memory Write 160kB");
- SetMenuState(false);
- _beginthread(DoMemW160, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_320:
- SetTitle("Running Memory Write 320kB");
- SetMenuState(false);
- _beginthread(DoMemW320, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_640:
- SetTitle("Running Memory Write 640kB");
- SetMenuState(false);
- _beginthread(DoMemW640, null, START_STACKSIZE, pv);
- break;
- case MI_MEMW_1280:
- SetTitle("Running Memory Write 1280kB");
- SetMenuState(false);
- _beginthread(DoMemW1280, null, START_STACKSIZE, pv);
- break;
- case MI_MEM_ALL:
- SetTitle("Running All Memory tests");
- SetMenuState(false);
- _beginthread(DoAllMem, null, START_STACKSIZE, pv);
- break;
- case MI_DIVE_VIDEO_BW:
- SetTitle("Running Video Bandwidth");
- SetMenuState(false);
- _beginthread(DoDiveVBW, null, START_STACKSIZE, pv);
- break;
- case MI_DIVE_ROTATE_SCREEN:
- SetTitle("Running DIVE fun");
- SetMenuState(false);
- _beginthread(DoDiveRot, null, START_STACKSIZE, pv);
- break;
- case MI_DIVE_MS_11:
- SetTitle("Running DIVE M->S 1:1");
- SetMenuState(false);
- _beginthread(DoDiveMS11, null, START_STACKSIZE, pv);
- break;
- case MI_DIVE_ALL:
- SetTitle("Running All DIVE tests");
- SetMenuState(false);
- _beginthread(DoAllDIVE, null, START_STACKSIZE, pv);
- break;
- case MI_DISKIO_AVSEEK:
- SetTitle("Running Average Seek Time");
- SetMenuState(false);
- _beginthread(DoDiskIOAvSeek, null, START_STACKSIZE, pv);
- break;
- case MI_DISKIO_CBXFER:
- SetTitle("Running Cache/Bus Transfer");
- SetMenuState(false);
- _beginthread(DoDiskCacheXfer, null, START_STACKSIZE, pv);
- break;
- case MI_DISKIO_TRANS_SPEED:
- SetTitle("Running Max. transfer speed");
- SetMenuState(false);
- _beginthread(DoDiskIOTransSpeed, null, START_STACKSIZE, pv);
- break;
- case MI_DISKIO_CPU_USAGE:
- SetTitle("Running CPU Usage percentage");
- SetMenuState(false);
- _beginthread(DoDiskIOCPUUsage, null, START_STACKSIZE, pv);
- break;
- case MI_DISKIO_ALL:
- SetTitle("Running All disk IO tests");
- SetMenuState(false);
- _beginthread(DoAllDiskIO, null, START_STACKSIZE, pv);
- break;
- }
- break;
-
- case WM_PAINT:
- {
- FATTRS fat;
- LONG match;
- FONTMETRICS fmMetrics ;
- HPS hpsPaint ;
- RECTL rclRect ;
- RECTL rclWindow ;
- ULONG ulCharHeight ;
- HWND hwndEnum ;
- HWND hwndFrame ;
- HENUM heEnum ;
- POINTL point;
- HRGN newHrgn, oldHrgn, dummy;
- s32 complexity;
- RECTL clipRect;
-
- if (!initialized) {
- initialized = true;
- }
-
- hpsPaint = WinBeginPaint ( hwndWnd,
- NULLHANDLE,
- &rclRect ) ;
-
- // This should work, but there was a bug in Warp II
- // newHrgn = GpiQueryClipRegion(hpsPaint);
- // complexity = GpiSetClipRegion(mainHps, newHrgn, &oldHrgn);
- // WinEndPaint(hpsPaint);
-
- GpiQueryClipBox(hpsPaint, &clipRect);
- clipRect.xRight++;
- clipRect.yTop++;
- newHrgn = GpiCreateRegion(mainHps, 1, &clipRect);
- GpiSetClipRegion(mainHps, newHrgn, &oldHrgn);
- if (NULLHANDLE != oldHrgn) {
- GpiDestroyRegion(mainHps, oldHrgn);
- }
-
- WinFillRect(mainHps, &rclRect, CLR_BLACK);
-
- WinQueryWindowRect ( hwndWnd, &rclWindow );
- UpdateWindow(mainHps,
- &rclWindow,
- scroll);
-
- oldscroll = scroll;
- WinEndPaint(hpsPaint);
- }
- break;
-
- case THR_DONE:
- SetTitle("Ready");
- SetMenuState(true);
- thread_running = false;
- break;
-
- case THR_UPDATE:
- UpdateAll();
- break;
-
- case WM_SIZE:
- {
- s32 tmp;
-
- WinQueryWindowRect(hwndClient, &rect);
-
- tmp = DISP_LINES * fontH - (rect.yTop - rect.yBottom);
-
- if (tmp < 0) tmp = 0;
- if (scroll > tmp) scroll = tmp;
-
- WinSendMsg( hwndVertScroll,
- SBM_SETSCROLLBAR,
- MPFROMSHORT(scroll),
- MPFROM2SHORT(0, tmp));
-
- WinSendMsg( hwndVertScroll,
- SBM_SETTHUMBSIZE,
- MPFROM2SHORT(rect.yTop - rect.yBottom, DISP_LINES * fontH),
- NULL);
-
- }
- break;
-
- case WM_VSCROLL:
- updateScroll = false;
- WinQueryWindowRect(hwndClient, &rect);
- switch( SHORT2FROMMP( mpParm2) )
- {
- case SB_LINEUP:
- scroll -= fontH;
- updateScroll = true;;
- break;
- case SB_LINEDOWN:
- scroll += fontH;
- updateScroll = true;;
- break;
- case SB_PAGEUP:
- scroll -= rect.yTop-rect.yBottom;
- updateScroll = true;;
- break;
- case SB_PAGEDOWN:
- scroll += rect.yTop-rect.yBottom;
- updateScroll = true;;
- break;
- case SB_SLIDERTRACK:
- case SB_SLIDERPOSITION:
- scroll = SHORT1FROMMP( mpParm2);
- /*(USHORT) WinSendMsg(hwndVertScroll,
- SBM_QUERYPOS, (MPARAM) NULL, (MPARAM) NULL);*/
- break;
- case SB_ENDSCROLL:
- break;
- default:
- break;
- }
-
- if (updateScroll) {
- WinQueryWindowRect(hwndClient, &rect);
- tmp = DISP_LINES * fontH - (rect.yTop - rect.yBottom);
- if (tmp < 0) tmp = 0;
- if (scroll > tmp) scroll = tmp;
- WinSendMsg( hwndVertScroll,
- SBM_SETSCROLLBAR,
- MPFROMSHORT(scroll),
- MPFROM2SHORT(0, tmp));
- WinSendMsg( hwndVertScroll,
- SBM_SETTHUMBSIZE,
- MPFROM2SHORT(rect.yTop - rect.yBottom, DISP_LINES * fontH),
- NULL);
- }
-
- tmp = DISP_LINES * fontH - (rect.yTop - rect.yBottom);
- if (scroll > tmp) scroll = tmp;
- if (scroll < 0) scroll = 0;
-
- WinScrollWindow(hwndClient, 0, scroll-oldscroll, NULL, NULL, NULLHANDLE, NULL, SW_INVALIDATERGN);
- break;
-
- case WM_ERASEBACKGROUND:
- return MRFROMSHORT ( false ); // No, we'll do this ourselves
-
- case WM_CHAR:
- switch (CHARMSG(&ulMsg)->vkey)
- {
- case VK_UP:
- case VK_DOWN:
- case VK_PAGEUP:
- case VK_PAGEDOWN:
- return WinSendMsg(hwndVertScroll, ulMsg, mpParm1, mpParm2);
- }
-
- default:
- return WinDefWindowProc ( hwndWnd,
- ulMsg,
- mpParm1,
- mpParm2 );
- }
-
- return MRFROMSHORT ( FALSE );
- }
-
- void
- PostFin(int onlyupdate) {
- if (onlyupdate) {
- WinPostMsg(hwndClient, THR_UPDATE, NULL, NULL);
- } else {
- WinPostMsg(hwndClient, THR_DONE, NULL, NULL);
- }
- }
-
- void err(char* s) {
- log(s);
- ErrorBox(s);
- exit(1);
- }
-
- void warn(char* s) {
- WarnBox(s);
- }
-
- static void
- SetTitle(char* s) {
- char tmp[100];
- sprintf(tmp, "SysBench %s - %s", SYSB_VER, s);
- WinSetWindowText(hwndFrame, tmp);
- }
-
- static void
- UpdateWindow(HPS hpsPaint, PRECTL pRect, s32 scrollValue) {
- static char tmp[256];
- s32 i, comp;
- s32 line = 0;
-
- // print header
-
- line++;
- // line++;
-
- for (comp = 0; comp < NUM_COMPONENTS; comp++) {
- // print title
- Print(line, 1, data.c[comp].title, pRect, scrollValue, hpsPaint, CLR_GREEN);
- line++;
- // print lines of data
- for (i = 0; i < data.c[comp].ndatalines; i++) {
- if (data.c[comp].datalines[i].value < 0.0)
- sprintf(tmp, "%-21s : --.--- %s", data.c[comp].datalines[i].entry,
- data.c[comp].datalines[i].unit);
- else
- sprintf(tmp, "%-21s : %12.3f %s", data.c[comp].datalines[i].entry,
- data.c[comp].datalines[i].value / data.c[comp].datalines[i].unit_val,
- data.c[comp].datalines[i].unit);
- Print(line, 3, tmp, pRect, scrollValue, hpsPaint, CLR_WHITE);
- line++;
- }
- Print(line, 3, "────────────────────────────────────────────────────────────", pRect, scrollValue, hpsPaint, CLR_PALEGRAY);
- line++;
- if (data.c[comp].total < 0.0)
- sprintf(tmp, "Total : --.--- %s",
- data.c[comp].unit_total);
- else
- sprintf(tmp, "Total : %12.3f %s", data.c[comp].total,
- data.c[comp].unit_total);
- Print(line, 3, tmp, pRect, scrollValue, hpsPaint, CLR_YELLOW);
- line++;
- line++;
- }
- }
-
- static void
- Print(s32 row, s32 col, char* string, PRECTL pRect, s32 scrollValue, HPS hpsPaint, s32 color)
- {
- RECTL printRect;
-
- printRect.xLeft = col * fontW;
- printRect.xRight = pRect->xRight;
- printRect.yTop = pRect->yTop - row * fontH + scrollValue;
- printRect.yBottom = printRect.yTop - fontH;
-
- WinDrawText(hpsPaint, -1, (PCH)string, &printRect, color, CLR_BLACK, DT_TOP | DT_LEFT);
- }
-
- static void
- PrintFile(s32 newlines, s32 col, char* string, FILE* fp) {
- s32 i;
- for (i = 0; i < col; i++)
- fprintf(fp, " ");
-
- fprintf(fp, "%s", string);
-
- for (i = 0; i < newlines; i++)
- fprintf(fp, "\n");
- }
-
- void
- InfoBox(char* s) {
- WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- s,
- "Info",
- WND_MESSAGEB,
- MB_OK | MB_INFORMATION | MB_APPLMODAL | MB_MOVEABLE);
- }
-
-
- void
- ErrorBox(char* s) {
- WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- s,
- "Error !",
- WND_MESSAGEB,
- MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE);
- }
-
-
- void
- WarnBox(char* s) {
- WinMessageBox(HWND_DESKTOP,
- hwndFrame,
- s,
- "Warning !",
- WND_MESSAGEB,
- MB_OK | MB_WARNING | MB_APPLMODAL | MB_MOVEABLE);
- }
-
- void
- UpdateAll(void) {
- RECTL rclWindow, cliprect;
- HRGN newHrgn, oldHrgn, dummy;
- s32 i, comp;
- bool calcav = true;
-
-
- // calculate averages
- for (comp = 0; comp < NUM_COMPONENTS; comp++) {
- calcav = true;
- for (i = 0; i < data.c[comp].ndatalines; i++) {
- calcav = calcav && (data.c[comp].datalines[i].value >= 0.0);
- }
- if (!calcav)
- continue;
- switch (comp) {
- case comp_gfx:
- data.c[comp_gfx].total = CalcGfxAv();
- break;
- case comp_cpuint:
- data.c[comp_cpuint].total = CalcCPUIntAv();
- break;
- case comp_cpufloat:
- data.c[comp_cpufloat].total = CalcCPUFloatAv();
- break;
- case comp_mem:
- data.c[comp_mem].total = CalcMemAv();
- break;
- case comp_dive:
- data.c[comp_dive].total = CalcDIVEAv();
- break;
- case comp_disk:
- data.c[comp_disk].total = CalcDiskIOAv();
- break;
- }
- }
-
- // update screen
- WinQueryWindowRect ( hwndClient, &rclWindow ); // update whole window
- cliprect.xLeft = rclWindow.xLeft;
- cliprect.xRight = rclWindow.xRight+1;
- cliprect.yBottom = rclWindow.yBottom;
- cliprect.yTop = rclWindow.yTop+1;
- newHrgn = GpiCreateRegion(mainHps, 1, &cliprect);
- GpiSetClipRegion(mainHps, newHrgn, &oldHrgn);
- if (NULLHANDLE != oldHrgn)
- GpiDestroyRegion(mainHps, oldHrgn);
- UpdateWindow(mainHps, &rclWindow, scroll);
- oldscroll = scroll;
- }
-
- static void SetMenuState(bool active) { // if active == true => all items enabled
- // otherw. all items but the about and close are disabled
- WinEnableMenuItem(hwndMenu, MI_PROJ_SAVE, active);
- WinEnableMenuItem(hwndMenu, MI_PROJ_ALL, active);
- WinEnableMenuItem(hwndMenu, MI_MENU_GFX, active);
- WinEnableMenuItem(hwndMenu, MI_MENU_CPUINT, active);
- WinEnableMenuItem(hwndMenu, MI_MENU_CPUFLOAT, active);
- WinEnableMenuItem(hwndMenu, MI_MENU_MEM, active);
- WinEnableMenuItem(hwndMenu, MI_MENU_DIVE, active);
- if (data.nr_fixed_disks)
- WinEnableMenuItem(hwndMenu, MI_MENU_DISKIO, active);
- }
-
-
- static void SaveResults(void) {
- FILE* fp;
- static char tmp[256];
- s32 i, comp;
- struct tm *newtime;
- time_t ltime;
-
- FILEDLG fild; /* File dialog info structure */
- char pszTitle[24] = "Save Results to file..."; /* Title of dialog */
- char pszFullFile[CCHMAXPATH] = "RESULT.TXT";/* File filter string */
- HWND hwndDlg; /* File dialog window */
-
- BYTE coproc;
- ULONG value[QSV_MAX] = {0};
- APIRET rc = 0UL;
- double meg = MB;
-
- ULONG ulCategory = IOCTL_OEMHLP; /* Device category */
- ULONG ulFunction = OEMHLP_GETMACHINEINFO; /* Device-specific function */
- UCHAR uchParms[1] = {0}; /* Input and output for function */
- ULONG ulParmLen = 1; /* Input and output parameter size */
- UCHAR uchDataArea[40] = {0}; /* Input and output data area */
- ULONG ulDataLen = 40; /* Input and output data size */
-
- HFILE filehandle;
- ULONG action;
-
- /* rc = DosOpen("OEMHLP$",
- &filehandle,
- &action,
- 0L,
- 0,
- 1,
- 0x40,
- 0L);
- if (rc == 0)
- {
- ulParmLen = strlen(uchParms); /* Length of input parameters */
-
- /* rc = DosDevIOCtl(filehandle, /* Handle to device */
- // ulCategory, /* Category of request */
- // ulFunction, /* Function being requested */
- // uchParms, /* Input/Output parameter list */
- // sizeof(uchParms), /* Maximum output parameter size */
- // &ulParmLen, /* Input: size of parameter list */
- /* Output: size of parameters returned */
- // uchDataArea, /* Input/Output data area */
- // sizeof(uchDataArea), /* Maximum output data size */
- // &ulDataLen); /* Input: size of input data area */
- /* Output: size of data returned */
- // }
- // DosClose(filehandle); /* Close handle to OEMHLP$ */
-
- memset(&fild, 0, sizeof(FILEDLG)); /* set fields in file dlg to zero */
-
- fild.cbSize = sizeof(FILEDLG); /* Size of structure */
- fild.fl = FDS_CENTER | FDS_SAVEAS_DIALOG | FDS_ENABLEFILELB ;
- /* FDS_* flags */
- fild.pszTitle = pszTitle; /* Dialog title string */
- strcpy(fild.szFullFile, pszFullFile); /* Initial path,file name, or file filter */
-
- hwndDlg = WinFileDlg(HWND_DESKTOP, hwndClient, &fild);
-
- if (hwndDlg && (fild.lReturn == DID_OK))
- {
- fp = fopen(fild.szFullFile, "wb");
- if (!fp)
- {
- WarnBox("Cannot open output file");
- return;
- }
- }
- else
- {
- return;
- }
-
- DosDevConfig(&coproc,DEVINFO_COPROCESSOR);
-
- rc = DosQuerySysInfo(QSV_DYN_PRI_VARIATION, QSV_TOTPHYSMEM, (PVOID)value, sizeof(ULONG)*QSV_MAX);
-
- time(<ime);
- newtime = localtime(<ime);
- fprintf(fp, "\n\nSysbench " SYSB_VER " result file created %s\n", asctime(newtime));
-
- fprintf(fp, "Coprocessor = %s, RAM = %3.2f MB\nPriority=%s, Maxwait=%d, Timeslice=(%d,%d).\n\n",
- (coproc ? "Yes" : "No"),
- (double)value[QSV_TOTPHYSMEM - QSV_DYN_PRI_VARIATION]/meg,
- (value[QSV_MAX_WAIT - QSV_DYN_PRI_VARIATION] ? "Dynamic" : "Absolute"),
- value[QSV_MAX_WAIT - QSV_DYN_PRI_VARIATION],
- value[QSV_MIN_SLICE - QSV_DYN_PRI_VARIATION],
- value[QSV_MAX_SLICE - QSV_DYN_PRI_VARIATION]);
-
- for (comp = 0; comp < NUM_COMPONENTS; comp++) {
- // print title
- PrintFile(1, 1, data.c[comp].title, fp);
- // print lines of data
- for (i = 0; i < data.c[comp].ndatalines; i++) {
- if (data.c[comp].datalines[i].value < 0.0)
- sprintf(tmp, "%-21s : --.--- %s", data.c[comp].datalines[i].entry,
- data.c[comp].datalines[i].unit);
- else
- sprintf(tmp, "%-21s : %12.3f %s", data.c[comp].datalines[i].entry,
- data.c[comp].datalines[i].value / data.c[comp].datalines[i].unit_val,
- data.c[comp].datalines[i].unit);
- PrintFile(1, 3, tmp, fp);
- }
- // PrintFile(1, 3, "────────────────────────────────────────────────────────────", fp);
- PrintFile(1, 3, "------------------------------------------------------------", fp);
- if (data.c[comp].total < 0.0)
- sprintf(tmp, "Total : --.--- %s",
- data.c[comp].unit_total);
- else
- sprintf(tmp, "Total : %12.3f %s", data.c[comp].total,
- data.c[comp].unit_total);
- PrintFile(2, 3, tmp, fp);
- }
-
- fclose(fp);
- }
-
-